package android_testsuite.mytest.seekbar;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import android_testsuite.R;

/**
 * Created by RenHui on 2015/6/8.
 */
public class SeekBarActivity extends Activity implements View.OnClickListener {
    private ImageView mGearOneView;
    private ImageView mGearTwoView;
    private ImageView mGearThreeView;
    private ImageView mGearFourView;
    private ImageView mGearFiveView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_seek_bar);
        setGearView();
    }

    private void setGearView() {
        mGearOneView = (ImageView) findViewById(R.id.gear_one);
        mGearTwoView = (ImageView) findViewById(R.id.gear_two);
        mGearThreeView = (ImageView) findViewById(R.id.gear_three);
        mGearFourView = (ImageView) findViewById(R.id.gear_four);
        mGearFiveView = (ImageView) findViewById(R.id.gear_five);
        mGearOneView.setOnClickListener(this);
        mGearTwoView.setOnClickListener(this);
        mGearThreeView.setOnClickListener(this);
        mGearFourView.setOnClickListener(this);
        mGearFiveView.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.gear_one:
                Toast.makeText(this, "0", Toast.LENGTH_SHORT).show();
                mGearOneView.setImageResource(R.drawable.circle_green);
                mGearTwoView.setImageResource(R.drawable.circle_gray);
                mGearThreeView.setImageResource(R.drawable.circle_gray);
                mGearFourView.setImageResource(R.drawable.circle_gray);
                mGearFiveView.setImageResource(R.drawable.circle_gray);
                break;
            case R.id.gear_two:
                Toast.makeText(this, "30", Toast.LENGTH_SHORT).show();
                mGearOneView.setImageResource(R.drawable.circle_gray);
                mGearTwoView.setImageResource(R.drawable.circle_green);
                mGearThreeView.setImageResource(R.drawable.circle_gray);
                mGearFourView.setImageResource(R.drawable.circle_gray);
                mGearFiveView.setImageResource(R.drawable.circle_gray);
                break;
            case R.id.gear_three:
                Toast.makeText(this, "60", Toast.LENGTH_SHORT).show();
                mGearOneView.setImageResource(R.drawable.circle_gray);
                mGearTwoView.setImageResource(R.drawable.circle_gray);
                mGearThreeView.setImageResource(R.drawable.circle_green);
                mGearFourView.setImageResource(R.drawable.circle_gray);
                mGearFiveView.setImageResource(R.drawable.circle_gray);
                break;
            case R.id.gear_four:
                Toast.makeText(this, "120", Toast.LENGTH_SHORT).show();
                mGearOneView.setImageResource(R.drawable.circle_gray);
                mGearTwoView.setImageResource(R.drawable.circle_gray);
                mGearThreeView.setImageResource(R.drawable.circle_gray);
                mGearFourView.setImageResource(R.drawable.circle_green);
                mGearFiveView.setImageResource(R.drawable.circle_gray);
                break;
            case R.id.gear_five:
                Toast.makeText(this, "300", Toast.LENGTH_SHORT).show();
                mGearOneView.setImageResource(R.drawable.circle_gray);
                mGearTwoView.setImageResource(R.drawable.circle_gray);
                mGearThreeView.setImageResource(R.drawable.circle_gray);
                mGearFourView.setImageResource(R.drawable.circle_gray);
                mGearFiveView.setImageResource(R.drawable.circle_green);
                break;
            default:
                mGearOneView.setImageResource(R.drawable.circle_gray);
                mGearTwoView.setImageResource(R.drawable.circle_gray);
                mGearThreeView.setImageResource(R.drawable.circle_gray);
                mGearFourView.setImageResource(R.drawable.circle_gray);
                mGearFiveView.setImageResource(R.drawable.circle_gray);
                break;
        }
    }
}
